package com.karina.visualization.chart.skins;

import com.karina.visualization.chart.client.Graphics;
import com.karina.visualization.chart.component.UpdateableObject.GradientType;
import com.karina.visualization.chart.model.ShapeModel;
import com.karina.visualization.styles.CSSDeclaretions;
import com.karina.visualization.styles.StylesManager;

abstract public class BaseSkin<T extends ShapeModel<?>> implements Skin<T> {

	protected GradientType gradient;

	protected double arpha = 1.0;

	protected double strok_width = 3;

	private String selectorName;

	private T data;

	@Override
	public void setSelectorName(String name) {
		selectorName = name;
	}

	protected CSSDeclaretions getStyleDeclaretion() {
		return StylesManager.getIntance().getStyle(selectorName);
	}

	protected CSSDeclaretions getStyleDeclaretion(String selector) {
		return StylesManager.getIntance().getStyle(selector);
	}

	protected void setStyle(Graphics graphics) {
		// if (gradient != null) {
		// ShapeModel data = getData();
		//
		// if (gradient == GradientType.LINER_GRAIDENT) {
		// gd = graphics.createLinearGradient(0, 0, data.getWidth(),
		// data.getHeight());
		//
		// graphics.setFillStyle(gd);
		// graphics.setStrokeStyle(gd);
		// } else if (gradient == GradientType.RADIOUS_GRAIDENT) {
		// double r = Math
		// .sqrt(Math.hypot(
		// new Integer(data.getWidth()).doubleValue(),
		// new Integer(data.getHeight()).doubleValue()));
		//
		// gd = graphics.createRadialGradient(0, 0, 0, data.getWidth(),
		// data.getHeight(), r);
		// graphics.setFillStyle(gd);
		// } else {
		// graphics.setFillStyle(color);
		// }

		// graphics.setStrokeStyle(borderColor);
		graphics.setLineWidth(strok_width);
		graphics.setGlobalAlpha(arpha);
		graphics.setJointCap("cap");
		// }
	}

	@Override
	public void setArapha(double arpha) {
		this.arpha = arpha;
	}

	@Override
	public void setData(T data) {
		this.data = data;
	}

	@Override
	public T getData() {
		return data;
	}

	@Override
	public void setLineWidth(double lineW) {
		this.strok_width = lineW;
	}
}
